var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    oil_info: '',
    ison: 0,
    isprice: 0,
    isshenhe: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getstatus();
  },
  /**
  * 生命周期函数--监听页面显示
  */
  onShow: function () {
    this.getstatus();
  },
  // 获取当前状态
  getstatus: function () {
    var that = this;
    var shopid = wx.getStorageSync('shop_id');
    var param = {
      url: 'api/shop/shopWashInfo',
      data: {
        shop_id: shopid
      },
      success: function (res) {
        console.log(res)
        var info = res.data.data.info;
        var isprice = that.data.ison;
        var isshenhe = that.data.isshenhe;
        if (info.shop_id) {
          if (info.review_info == null){
            isprice = 1;
            isshenhe = 0;
          }
          if (info.review_info != null) {
            if (info.review_info.business){
              isprice = 1;
              isshenhe = 1;
            }
           
          }
        } else {
          isprice = 0;
          isshenhe = 0
        }
        that.setData({
          oil_info: info,
          ison: res.data.data.ison,
          isprice: isprice,
          isshenhe: isshenhe
        })
      }
    };
    app.post(param);
  },

 

  setPrice: function () {
    wx.navigateTo({
      url: '/pages/shangjia/wash-setprice/wash-setprice',
    })
  },
  // 开始营业
  yingye: function () {
    this.changestatus(1)
  },

  buyingye: function () {
    this.changestatus(0)
  },
  changestatus: function (ison) {
    var that = this;
    var shopid = wx.getStorageSync('shop_id');
    var param = {
      url: 'api/shop/changeIson',
      data: {
        shop_id: shopid,
        ison: ison
      },
      success: function (res) {
        wx.showToast({
          title: res.data.msg,
          icon: 'none',
          duration: 2000
        })
        if (res.data.code == 1) {
          that.setData({
            ison: ison
          })
        }
      }

    }
    app.post(param);
  }
})